#coding=utf-8
import requests,json
import time

'''
#查看是否成功，访问（改id）id详情在 webserver.log
https://xiapi.xiapibuy.com/shop/18250699  
https://seller.xiapi.shopee.cn/
'''

HTTP_HEADER = {
        "Accept": "application/json",
        "Accept-Encoding": "gzip, deflate, br",
        "Accept-Language": "zh-CN,zh;q=0.9",
        "Cache-Control": "no-cache",
        "Connection": "keep-alive",
        "Pragma": "no-cache",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36",
        
        }

#cookie = {"SPC_EC":"AJUOyRStwP7jxG7VbnppT9q3RoK1KEtuqsZl3zF5G6Hqc6GyCf8Y7EUSHCCowDXVEI7mLIO/BK33QYN0qBZ0SfPq1Foy52iD/D6SBfPx144NDdIvb2m6dsx37Ct3EbYXV7AU2YahlZO6d5ojT9BgDXocNem9kn9cep2PzEelbj0="}

#01 生成appkey
_data = {
    'user_appid':'testxxxxxx',
    'user_time_control':'2022-08-22T12:22:12',
}
res = requests.post('http://127.0.0.1:8094/user/generate',headers=HTTP_HEADER,data=json.dumps(_data))
print(json.loads(res.text))

#02 设置token,经常调用
_data_token ={
    'user_appkey':'f0b68cdc-d275-11ea-b834-001a7dda7114',
    'user_token':'0TYszfVytEgnhpihJUGUMDcHZizGYWVAZ0mK6dVPFYuG162olc8n87OwOeCK6IfKOVwNhHbOQzgQbCP4gBmTXmrW4/Ok+iYWSdPRaghIkiBTQjqf+v+K7OjPX5qkiTSDuwpA2RWCc15o37ByN+Y8QBdUzTma/A/GOLykuhgYj+E='
}
res = requests.post('http://127.0.0.1:8094/spider/settoken',headers=HTTP_HEADER,json=_data_token)
print (json.loads(res.text))


##03 指定店铺开始关注
## https://xiapi.xiapibuy.com/%E9%9F%93%E5%9C%8B-Median-93-%E5%BC%B7%E6%95%88%E6%B7%A8%E7%99%BD%E5%8E%BB%E5%9E%A2%E7%89%99%E8%86%8F-120g-(%E9%98%B2%E8%AD%B7%E6%8A%97%E8%8F%8C-%E6%B7%A8%E7%99%BD-%E7%89%99%E5%9E%A2%E5%8F%A3%E8%87%AD-%E7%89%99%E5%91%A8%E8%AD%B7%E7%90%86)-3%E5%85%A5%E7%B5%84-i.37137599.6402742233
## https://xiapi.xiapibuy.com/%E3%80%90A12%E3%80%91%F0%9F%94%A5%E5%8F%B0%E7%81%A3%E7%8F%BE%E8%B2%A8%F0%9F%94%A5%E5%85%A9%E6%AC%BE%E5%A4%9A%E8%89%B2%E6%A3%89%E8%B3%AA%E5%A5%BD%E7%A9%BF%F0%9F%91%8D%F0%9F%8F%BB%E5%8F%AF%E6%8B%86%E8%83%B8%E5%A2%8A%E4%BA%A4%E5%8F%89%E7%BE%8E%E8%83%8CBra%F0%9F%92%95%E5%BD%88%E5%8A%9B%E8%83%8C%E5%BF%83%F0%9F%92%95%E5%B0%8F%E5%8F%AF%E6%84%9B%F0%9F%92%95%E5%85%A7%E8%A1%A3%F0%9F%92%95%E8%83%B8%E7%BD%A9-i.28969561.1298245850
_data_itemfollowing ={
    'user_appkey':'f0b68cdc-d275-11ea-b834-001a7dda7114',
    'item_url':'https://xiapi.xiapibuy.com/%E3%80%90A12%E3%80%91%F0%9F%94%A5%E5%8F%B0%E7%81%A3%E7%8F%BE%E8%B2%A8%F0%9F%94%A5%E5%85%A9%E6%AC%BE%E5%A4%9A%E8%89%B2%E6%A3%89%E8%B3%AA%E5%A5%BD%E7%A9%BF%F0%9F%91%8D%F0%9F%8F%BB%E5%8F%AF%E6%8B%86%E8%83%B8%E5%A2%8A%E4%BA%A4%E5%8F%89%E7%BE%8E%E8%83%8CBra%F0%9F%92%95%E5%BD%88%E5%8A%9B%E8%83%8C%E5%BF%83%F0%9F%92%95%E5%B0%8F%E5%8F%AF%E6%84%9B%F0%9F%92%95%E5%85%A7%E8%A1%A3%F0%9F%92%95%E8%83%B8%E7%BD%A9-i.28969561.1298245850'
}
res = requests.post('http://127.0.0.1:8094/spider/itemfollowing',headers=HTTP_HEADER,json=_data_itemfollowing)
print (json.loads(res.text))
exit()
#04 指定分类开始关注
_data_following ={
    'user_appkey':'f0b68cdc-d275-11ea-b834-001a7dda7114',
    'cat_id': 62,  #会有对应表
    'cat_shop_count':50,  #默认50
    'total_shop_follower':20,  #默认一次关注20个
    'auto_switch':'enable'
}
res = requests.post('http://127.0.0.1:8094/spider/following',headers=HTTP_HEADER,json=_data_following)
print(json.loads(res.text))
#